function PlotResults( electrNr )

electrodes = GetElectrodes();
if nargin == 1
    electrodes = electrodes(electrNr);
end
% PlotResultsBySEP(1:27, electrodes);
PlotResultsByEP(1:27, electrodes);

end

function PlotResultsBySEP(subjectNrs, electrodes)
load('Output.mat');
% skipnext = true;
for i=subjectNrs
    disp(['====> Subject: ' output.subjects(i).Name]);
    %     if skipnext; continue; end;
    for e=1:length(electrodes)
        electrode = electrodes{e};
        for p=1:size(output.results(i).period,2)
            f = PlotResultsSEP(output, i, electrode, p);
            saveFigure(f, 'J:\PeakAnalysis\Results\', [output.subjects(i).Name ' P' num2str(p) ' - ' electrode]);
            close(f);
        end
    end
end
end

function PlotResultsByEP(subjectNrs, electrodes)
load('Output.mat');
% skipnext = true;
disp(['====> Subjects:']);
for i = subjectNrs
    disp(['     ' output.subjects(i).Name]);
end
%     if skipnext; continue; end;
for e=1:length(electrodes)
    electrode = electrodes{e};
    for p=1:4 % assume there are 4 periods to loop over!
        f = PlotResultsEP(output, subjectNrs, electrode, p);
        saveFigure(f, 'J:\PeakAnalysis\Results\', ['P' num2str(p) ' - ' electrode]);
        close(f);
    end
end
end